package com.etc.common;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.convert.converter.Converter;
/**
 * 
 * Filename:    StringToDate.java  
 * Description:  birthday=2020-03-02    2020-03-02-->java。util.Date 
 * Copyright:   Copyright (c) 2018-2019 All Rights Reserved.
 * Company:     chinasofti.com Inc.
 * @author:     mazheng 
 * @version:    1.0  
 * Create at:   2020年3月3日 下午4:00:15  
 *  
 * Modification History:  
 * Date         Author      Version     Description  
 * ------------------------------------------------------------------  
 * 2020年3月3日      mazheng      1.0         1.0 Version  
 *
 */
public class StringToDate implements Converter<String, Date> {
    private static final Logger logger = LoggerFactory.getLogger(StringToDate.class.getName());

    public static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd"); 
    @Override
    public Date convert(String source) {

        try {
            Date d = SDF.parse(source);
            return d;
        } catch (ParseException e) {
//            e.printStackTrace();
            logger.warn(e.getMessage() + "类型转换有点问题");
            return null;
        }
        
    }

}
